<?php
// ========================== 文件说明 ==========================//
// 本文件说明：提交数据操作
// --------------------------------------------------------------//
// 本程序作者：angel
// --------------------------------------------------------------//
// 本程序版本：SaBlog-X Ver 1.6
// --------------------------------------------------------------//
// 本程序主页：http://www.sablog.net
// ========================== 开发环境 ==========================//
// register_globals = Off
// --------------------------------------------------------------//
// magic_quotes_gpc = On
// --------------------------------------------------------------//
// safe_mode = On
// --------------------------------------------------------------//
// Windows server 2003 & Linux & FreeBSD
// --------------------------------------------------------------//
// Apache/1.3.33 & PHP/4.3.2 & MySQL/4.0.17
// --------------------------------------------------------------//
// Apache/1.3.34 & PHP/4.4.1 & MySQL/5.0.16
// --------------------------------------------------------------//
// Apache/2.0.55 & PHP/5.1.1 & MySQL/5.0.15
// --------------------------------------------------------------//
// Copyright (C) Security Angel Team All Rights Reserved.
// ==============================================================//

require_once('global.php');

// 获得文件扩展名
function getextension($filename) {
	$pathinfo = pathinfo($filename);
	return $pathinfo['extension'];
}

//if($_SERVER['REQUEST_METHOD'] == 'POST' && (empty($_SERVER['HTTP_REFERER']) || $_POST['formhash'] != formhash() || preg_replace("/https?:\/\/([^\:\/]+).*/i", "\\1", $_SERVER['HTTP_REFERER']) !== preg_replace("/([^\:]+).*/", "\\1", $_SERVER['HTTP_HOST']))) {
//	message('您的请求来路不正确,无法提交');
//}

//添加评论
if($_POST['action'] == 'addcomment') {
	if ($options['close_comment']) {
		message('禁止发表评论', $referer);
	}
	$articleid = intval($_POST['articleid']);
	$username = trim($_POST['username']);
	$password = $_POST['password'];
	$email = trim($_POST['email']);
	$url = trim($_POST['url']);
	$content = sax_addslashes(trim($_POST['content']));
	//把评论内容保存到cookie里以免丢失
	scookie('cmcontent', $content, $login_life);

	if (!$articleid) {
		message('缺少必要参数', $options['url']);
	}

	//禁止IP
	if ($options['banip_enable'] && $options['ban_ip']) {
		$options['ban_ip'] = str_replace('，', ',', $options['ban_ip']);
		$ban_ips = explode(',', $options['ban_ip']);
		if (is_array($ban_ips) && count($ban_ips)) {
			foreach ($ban_ips AS $ban_ip) {
				$ban_ip = str_replace( '\*', '.*', preg_quote($ban_ip, "/") );
				if (preg_match("/^$ban_ip/", $onlineip)) {
					message('您的IP已经被系统禁止发表评论');
				}
			}
		}
	}

	$article = $DB->fetch_one_array("SELECT dateline,alias,closecomment FROM {$db_prefix}articles WHERE articleid='$articleid'");

	$article['url'] = getpermalink($articleid, $article['alias'], 0, sadate('Y/m/d',$article['dateline']));

	if ($article['closecomment']) {
		message('本文不允许发表评论', $article['url']);
	}

	if ($options['seccode'] && $sax_group != 1 && $sax_group !=2) {
		$clientcode = $_POST['clientcode'];
		if (!$clientcode || strtolower($clientcode) != strtolower($seccode)) {
			$seccode = random(4, 1);
			updatesession();
			message('验证码错误,请返回重新输入.', $login_url);
		}
	}

	//如果没有登陆
	if (!$sax_uid || !$sax_pw || !$sax_logincount || !$sax_hash) {
		if(!$username || strlen($username) > 30) {
			message('用户名为空或用户名太长');
		}
		$name_key = array("\\",'&',' ',"'",'"','/','*',',','<','>',"\r","\t","\n",'#','$','(',')','%','@','+','?',';','^');
		foreach($name_key as $value){
			if (strpos($username,$value) !== false){
				message('此用户名包含不可接受字符或被管理员屏蔽,请选择其它用户名');
			}
		}

		if (!isemail($email)) {
			message('E-mail地址错误');
		}
		if (!isurl($url)) {
			message('网站URL错误', $article['url'].'#addcomment');
		}

		$username = char_cv($username);

		if ($options['censoruser']) {
			$options['censoruser'] = str_replace('，', ',', $options['censoruser']);
			$banname=explode(',',$options['censoruser']);
			foreach($banname as $value){
				if (strpos($username,$value) !== false){
					message('此用户名包含不可接受字符或被管理员屏蔽.', $article['url'].'#addcomment');
				}
			}
		}

		$r = $DB->fetch_one_array("SELECT userid FROM {$db_prefix}users WHERE username='$username' LIMIT 1");
		if($r['userid']) {
			message('该用户名已存在,如果是您注册的,请先登陆.');
		}

		//把用户名和URL信息保存到cookie
		scookie('comment_username',$username,$login_life);
		scookie('comment_email',$email,$login_life);
		scookie('comment_url',$url,$login_life);
		$email = char_cv($email);
		$url = char_cv($url);

	} else {
		$username = $sax_user;
		$email = char_cv($sax_email);
		$url = char_cv($sax_url);
	}

	// 不属于撰写组以上的成员需要做审核检查
	if ($sax_group != 1 && $sax_group != 2) {
		// 检查限制选项
		if ($options['audit_comment']) {
			$spam = true;
		} elseif ($options['spam_enable']) {
			//链接次数
			if (substr_count($content, 'http://') >= $options['spam_url_num']) {
				$spam = true;
			}
			//禁止词语
			if ($options['spam_words']) {
				$options['spam_words'] = str_replace('，', ',', $options['spam_words']);
				$badwords = explode(',', $options['spam_words']);
				if (is_array($badwords) && count($badwords) ) {
					foreach ($badwords as $n) {
						if ($n) {
							if (preg_match( "/".preg_quote($n, '/' )."/i", $content)) {
								$spam = true;
								break;
							}
						}
					}
				}
			}
			//内容长度
			if (strlen($content) >= $options['spam_content_size']) {
				$spam = true;
			}
		} else {
			$spam = false;
		}
	} else {
		$spam = false;
	}

	$visible = $spam ? '0' : '1';

	if ($sax_group != 1 && $sax_group != 2) {
		$lastposttime = $user['lastpost'] ? $user['lastpost'] : $_COOKIE['comment_post_time'];
		if ($options['comment_post_space'] && $timestamp - $lastposttime <= $options['comment_post_space'] && $sax_group != 1){
			message('为防止灌水,发表评论时间间隔为'.$options['comment_post_space'].'秒.', $article['url'].'#addcomment');
		}
	}

	$checkcontent = checkcontent($content);
	if ($checkcontent) {
		message($checkcontent, $article['url'].'#addcomment');
	}

    $r = $DB->fetch_one_array("SELECT commentid FROM {$db_prefix}comments WHERE articleid='$articleid' AND author='$username' AND content='$content' LIMIT 1");
    if($r['commentid']) {
		message('该评论已存在');
    }

    $DB->query("INSERT INTO {$db_prefix}comments (articleid, author, email, url, dateline, content, ipaddress, visible) VALUES ('$articleid', '$username', '$email', '$url', '$timestamp', '$content', '$onlineip', '$visible')");
	$cmid = $DB->insert_id();
	if ($sax_uid) {
		$DB->unbuffered_query("UPDATE {$db_prefix}users SET lastpost='$timestamp' WHERE userid='$sax_uid'");
		// 更新用户最后发表时间
	}
	if (!$spam) {
		// 如果不是垃圾则更新当前文章评论数
		$DB->unbuffered_query("UPDATE {$db_prefix}articles SET comments=comments+1 WHERE articleid='$articleid'");
		$DB->unbuffered_query("UPDATE {$db_prefix}statistics SET comment_count=comment_count+1");
		require_once(SABLOG_ROOT.'include/func/cache.func.php');
		newcomments_recache();
		statistics_recache();
	}
	scookie('comment_post_time',$timestamp);
	// 跳转到最新发表的评论
	$cmnum = '#cm'.$cmid;
	$article_comment_num = intval($options['article_comment_num']);
	if ($article_comment_num) {
		$cpost = $DB->fetch_one_array("SELECT COUNT(*) as comment FROM {$db_prefix}comments WHERE articleid='$articleid' AND visible='1' AND commentid<='$cmid'");
		if (($cpost['comment'] / $article_comment_num) <= 1 ) {
			$page = 1;
		} else {
			$page = @ceil(($cpost['comment']) / $article_comment_num);
			$article['url'] = getpermalink($articleid, $article['alias'], $page, sadate('Y/m/d',$article['dateline']));
		}
	} else {
		$page = 1;
	}
	if ($spam) {
		message('添加评论成功,目前发表评论需要管理员审核才会显示,请耐心等待管理员审核.', $article['url']);
	}

	dcookies('cmcontent');

	if ($options['comment_order']) { //新评论靠后排序
		if ($options['showmsg']) {
			message('添加评论成功.', $article['url'].$cmnum);
		} else {
			@header('Location: '.$article['url'].$cmnum);
		}
	} else {
		if ($options['showmsg']) {
			message('添加评论成功.', $article['url'].'#comment');
		} else {
			@header('Location: '.$article['url'].'#comment');
		}
	}
}

//搜索
if ($_POST['action'] == 'search') {
	$keywords = sax_addslashes(trim($_POST['keywords'] ? $_POST['keywords'] : $_GET['keywords']));
	if (!$keywords) {
		message('您没有指定要搜索的关键字.', $search_url);
	} else {
		if(strlen($keywords) < $options['search_keywords_min_len']) {
			message('关键字不能少于'.$options['search_keywords_min_len'].'个字节.', $search_url);
		}

		$cid = $_POST['cid'];
		//分类
		$catearray = array();
		if($cid) {
			foreach((is_array($cid) ? $cid : explode('_', $cid)) as $cateid) {
				if($cateid = intval(trim($cateid))) {
					$catearray[] = $cateid;
				}
			}
		}
		$cids = $comma = '';
		foreach($catecache as $data) {
			if(!$catearray || in_array($data['cid'], $catearray)) {
				$cids .= $comma.intval($data['cid']);
				$comma = ',';
			}
		}

		$searchstring = sax_addslashes($keywords).'|'.intval($searchin).'|'.sax_addslashes($sortby).'|'.sax_addslashes($orderby).'|'.sax_addslashes($cids).'|'.intval($dateline).'|'.intval($before);

		$searchindex = array('id' => 0, 'dateline' => '0');
		$query = $DB->query("SELECT searchid, dateline,
			('".$options['search_post_space']."'<>'0' AND ".($sax_uid ? "uid='$sax_uid'" : "ipaddress='$onlineip'")." AND $timestamp-dateline<".$options['search_post_space'].") AS flood, (searchstring='$searchstring' AND expiration>'$timestamp') AS indexvalid
			FROM {$db_prefix}searchindex
			WHERE ('".$options['search_post_space']."'<>'0' AND ".($sax_uid ? "uid='$sax_uid'" : "ipaddress='$onlineip'")." AND $timestamp-dateline<".$options['search_post_space'].") ORDER BY flood");

		while($index = $DB->fetch_array($query)) {
			if($index['indexvalid'] && $index['dateline'] > $searchindex['dateline']) {
				$searchindex = array('id' => $index['searchid'], 'dateline' => $index['dateline']);
				break;
			} elseif($index['flood'] && $sax_group != 1 &&  $sax_group != 2) {
				message('对不起,您在 '.$options['search_post_space'].' 秒内只能进行一次搜索.', $search_url);
			}
		}

		if($searchindex['id']) {
			$searchid = $searchindex['id'];
			$gourl = './?action=article&amp;searchid='.$searchid;
		} else {
			$keywords = str_replace("_","\_",$keywords);
			$keywords = str_replace("%","\%",$keywords);
			if(preg_match("(AND|\+|&|\s)", $keywords) && !preg_match("(OR|\|)", $keywords)) {
				$andor = ' AND ';
				$sqltxtsrch = '1';
				$keywords = preg_replace("/( AND |&| )/is", "+", $keywords);
			} else {
				$andor = ' OR ';
				$sqltxtsrch = '0';
				$keywords = preg_replace("/( OR |\|)/is", "+", $keywords);
			}
			$keywords = str_replace('*', '%', addcslashes($keywords, '%_'));
			foreach(explode("+", $keywords) AS $text) {
				$text = trim($text);
				if($text) {
					$sqltxtsrch .= $andor;
					$sqltxtsrch .= ($_POST['searchin'] == 'content') ? "(content LIKE '%".$text."%' OR description LIKE '%".$text."%' OR title LIKE '%".$text."%')" : "title LIKE '%".$text."%'";
				}
			}

			$query_sql = "SELECT ".($_POST['searchin'] == 'content' ? 'DISTINCT' : '')." articleid FROM {$db_prefix}articles WHERE visible='1'";

			if ($cids) {
				$query_sql .= " AND cid IN ($cids)";
			}

			$sortby = in_array($_POST['sortby'], array('dateline', 'views', 'comments')) ? $_POST['sortby'] : 'dateline';

			$orderby = $_POST['orderby'] == 'asc' ? 'asc' : 'desc';

			//时间
			$dateline = intval($_POST['dateline']);
			if($dateline) {
				$tmpsql = $before ? '<=' : '>=';
				$tmpsql .= $timestamp - $dateline;
				$query_sql .= ' AND dateline '.$tmpsql;
			}
			$query_sql .= " AND ($sqltxtsrch) ORDER BY $sortby $orderby LIMIT 500"; //搜索500个出来足够了.保证效率.反正一般BLOG也没有多少数据.

			$totals = $ids = 0;
			$query = $DB->query($query_sql);
			while($article = $DB->fetch_array($query)) {
				$ids .= ','.$article['articleid'];
				$totals++;
			}

			$DB->free_result($query);

			$DB->query("INSERT INTO {$db_prefix}searchindex (keywords, searchstring, dateline, expiration, sortby, orderby, totals, ids, ipaddress, uid) VALUES ('".char_cv($keywords)."', '$searchstring', '$timestamp', '".($timestamp+3600)."', '$sortby', '$orderby', '$totals', '$ids', '$onlineip', '$sax_uid')");
			$searchid = $DB->insert_id();

			$gourl = './?action=article&amp;searchid='.$searchid;
		}
		if ($options['showmsg']) {
			message('搜索成功完成,现在将转入结果页面.', $gourl);
		} else {
			$gourl = str_replace("&amp;", "&", $gourl);
			@header("Location: ".$gourl);
		}
	}
}
//寒假实践上交
if ($_POST['action'] == 'winterprac') {
	$step = $_COOKIE['regstep'] ? $_COOKIE['regstep'] : 0;
	if(!$step || $step == 1) {
		scookie('regstep', '1', 1800);
		$school = str_replace(array('"',"'",'/','|',',','(',')','\\','<','>'), '', trim($_POST['school']));
		$proj = str_replace(array('"',"'",'/','|',',','(',')','\\','<','>'), '', trim($_POST['proj']));
		$team = str_replace(array('"',"'",'/','|',',','(',')','\\','<','>'), '', trim($_POST['team']));
		scookie('school', $school, 3600);
		scookie('proj', $proj, 3600);
		scookie('team', $team, 3600);
		if(!empty($school) && !empty($proj) && !empty($team)) {
			scookie('regstep', '2', 1800);
		}
		@header("Location: ".$options['url']."index.php?action=actreg");//地址还没有写
	} elseif($step == 2) {
		$leader = str_replace(array('"',"'",'/','|',',','(',')','\\','<','>'), '', trim($_POST['leader']));
		$member = str_replace(array('"',"'",'/','|','(',')','\\','<','>'), '', trim($_POST['member']));
		$email = str_replace(array('"',"'",'/','|','(',')','\\','<','>'), '', trim($_POST['email']));
		$mphone = str_replace(array('"',"'",'/','|','(',')','\\','<','>'), '', trim($_POST['mphone']));
		scookie('leader', $leader, 3600);
		scookie('member', $member, 3600);
		scookie('mphone', $mphone, 3600);
		scookie('email', $email, 3600);
		if (!isemail($email)) {
			scookie('regstep', '2', 1800);
			dcookies('email');
			message('E-mail地址错误', $options['url']."index.php?action=actreg");
		}
		if (strlen($mphone) != 11) {
			scookie('regstep', '2', 1800);
			dcookies('mphone');
			message('手机号错误', $options['url']."index.php?action=actreg");
		}
		if(!empty($leader) && !empty($member) && !empty($email) && !empty($mphone)) {
			scookie('regstep', '3', 1800);
		}
		@header("Location: ".$options['url']."index.php?action=actreg");//地址还没有写
	} elseif($step == 3) {

		if(!empty($_COOKIE['leader']) && !empty($_COOKIE['member']) && !empty($_COOKIE['email']) && !empty($_COOKIE['mphone']) && !empty($_COOKIE['school']) && !empty($_COOKIE['proj']) && !empty($_COOKIE['team'])) {
			if($_FILES['userfile']['error'] == 1) {
				message("上传的文件过大，请精简之后，重新上传", $options['url']."index.php?action=actreg", 30);
			}
			if($_FILES['userfile']['error'] != 0) {
				message("上传出错，重新上传", $options['url']."index.php?action=actreg", 30);
			}
			$uploaddir = SABLOG_ROOT.'uploads/date_'.date('m').'_'.date('d').'/';
			$uploadfile = $uploaddir. $_FILES['userfile']['name'];
			$fnamehash = md5(uniqid(microtime()));
			if(!is_dir($uploaddir)) {
				mkdir($uploaddir, 0777);
				@chmod($uploaddir, 0777);
				fclose(fopen($uploaddir.'index.htm', 'w'));
			}
			$attach = array();
			foreach ($_FILES['userfile'] as $key => $var ) {
				$attach[$key] = $var;
			}
			$attach['ext'] = getextension($attach['name']);
			if ($attach['size'] < 5242880) {
				if ($attach['ext'] == 'doc') {
					if (move_uploaded_file($attach['tmp_name'], $uploaddir . $fnamehash .'.'. $attach['ext'])) {
						//检查重复内容
						$rs = $DB->fetch_one_array("SELECT * FROM {$db_prefix}winterprac WHERE proj='$proj' OR leader='$leader'");
						if($rs) {
							if($rs['proj'] == $proj) {
								dcookies('proj');
								scookie('regstep', '1', 1800);
								message("实践项目名称重复", $options['url']."index.php?action=actreg", 60);
							} else {
								scookie('regstep', '2', 1800);
								dcookies('leader');
								message("队长重复", $options['url']."index.php?action=actreg", 60);
							}
						}
						//写入数据库
						$rs = $DB->query("INSERT INTO {$db_prefix}winterprac (id,school,team,proj,leader,member,email,mphone,files,date) VALUES ('' , '".$school."' , '".$team."', '".$proj."', '".$leader."', '".$member."', '".$email."', '".$mphone."', 'uploads/date_".date('m')."_".date('d')."/".$fnamehash.".".$attach['ext']."', '".time()."')");
						if($rs) {
							dcookies('regstep');
							dcookies('school');
							dcookies('team');
							dcookies('proj');
							dcookies('leader');
							dcookies('member');
							dcookies('mphone');
							message('上传成功，谢谢关注康腾实践中心', $options['url']."index.php?action=actreg", 60);
						} else {
							message('上传出现错误，请后退重试。<br />如果多次无法成功上传，请联系<a href="mailto:huangjin@content.org.cn" >huangjin@content.org.cn</a>' ,60);
						}
					} else {
						message('上传出现错误，请后退重试。<br />如果多次无法成功上传，请联系<a href="mailto:huangjin@content.org.cn" >huangjin@content.org.cn</a>', 60);
					}
				}
				else message('对不起，只能上传Word2003格式的文档.', 60);
			} else {
				message('对不起，您上传的Word2003文档过大，本次上传文档并非评奖所用，请删除掉文档内的图片后，再次上传。', 60);
			}
		} else {
			scookie('regstep', '1', 1800);
			@header("Location: ".$options['url']."index.php?action=actreg");
		}
	}
}
if($_POST['action'] == 'reg') {
	//安全过滤
	$university =	str_replace(array('"',"'",'/','|',',','(',')','\\','<','>'), '', trim($_POST['university']));
	$school =	str_replace(array('"',"'",'/','|',',','(',')','\\','<','>'), '', trim($_POST['school']));
	$team =		str_replace(array('"',"'",'/','|',',','(',')','\\','<','>'), '', trim($_POST['team']));
	$leader =	str_replace(array('"',"'",'/','|',',','(',')','\\','<','>'), '', trim($_POST['leader']));
	$cellphone = str_replace(array('"',"'",'/','|',',','(',')','\\','<','>'), '', trim($_POST['cellphone']));
	$email = 	str_replace(array('"',"'",'/','|',',','(',')','\\','<','>'), '', trim($_POST['email']));

	//cookies保存信息
	scookie('university',$university, 3600);
	scookie('team',$team, 3600);
	scookie('school',$project, 3600);
	scookie('leader',$leader, 3600);
	scookie('cellphone',$cellphone, 3600);
	scookie('email',$email, 3600);
	
	//有效性检查
	if(empty($university) && empty($team) && empty($leader) && empty($cellphone) && empty($email)) {
		message('请填写完整信息');
	}
	if(!isemail($email)) {
		dcookies('email');
		message('e-mail地址错误');
	}
	if(strlen($cellphone) != 11) {
		dcookies('cellphone');
		message('手机号不正确');
	}
	$r = $DB->fetch_one_array("SELECT cellphone, email FROM {$db_prefix}reg WHERE cellphone='$cellphone' OR email='$email' LIMIT 1");
	if(!empty($r)) {
		message('你已经成功报名,请查看邮箱,如有疑问,请发送邮件至2009@content.org.cn');
	}
	
			if($_FILES['userfile']['error'] == 1) {
				message("上传的文件过大，请精简之后，重新上传", $options['url']."index.php?action=reg", 30);
			}
			if($_FILES['userfile']['error'] != 0) {
				message("上传出错，重新上传", $options['url']."index.php?action=reg", 30);
			}
			$uploaddir = SABLOG_ROOT.'uploads/date_'.date('m').'_'.date('d').'/';
			$uploadfile = $uploaddir. $_FILES['userfile']['name'];
			$fnamehash = md5(uniqid(microtime()));
			if(!is_dir($uploaddir)) {
				mkdir($uploaddir, 0777);
				@chmod($uploaddir, 0777);
				fclose(fopen($uploaddir.'index.htm', 'w'));
			}
			$attach = array();
			foreach ($_FILES['userfile'] as $key => $var ) {
				$attach[$key] = $var;
			}
			$attach['ext'] = getextension($attach['name']);
			if ($attach['size'] < 5242880) {
				if ($attach['ext'] == 'doc' || $attach['ext'] == 'docx') {
					if (move_uploaded_file($attach['tmp_name'], $uploaddir . $fnamehash .'.'. $attach['ext'])) {
/*						//检查重复内容
						$rs = $DB->fetch_one_array("SELECT * FROM {$db_prefix}winterprac WHERE proj='$proj' OR leader='$leader'");
						if($rs) {
							if($rs['proj'] == $proj) {
								dcookies('proj');
								scookie('regstep', '1', 1800);
								message("实践项目名称重复", $options['url']."index.php?action=actreg", 60);
							} else {
								scookie('regstep', '2', 1800);
								dcookies('leader');
								message("队长重复", $options['url']."index.php?action=actreg", 60);
							}
						}*/
						//数据写入数据库
						$rs = $DB->query("INSERT INTO {$db_prefix}reg (university,school,team,leader,cellphone,email,date,filename,filetype,filesize,filepath) VALUES ('".$university."', '".$school."', '".$team."', '".$leader."', '".$cellphone."', '".$email."', '".time()."', '".$_FILES['userfile']['name']."', '".$_FILES['userfile']['type']."', '".$_FILES['userfile']['size']."', 'uploads/date_".date('m')."_".date('d')."/".$fnamehash.".".$attach['ext']."')");
						if($DB->geterrdesc() != '') {
							message("出错了,问题可能不在于您,请稍候再访问本页面");
							sendmail("error 报警", "alvingin@gmail.com", $DB->geterrno()."<br />".$university."<br />".$school."<br />".$team."<br />".$leader."<br />".$cellphone."<br />".$email."<br />".time());
						}
						sendmail($leader, $email);
						if($rs) {
							//删除cookies保存信息
							dcookies('university');
							dcookies('team');
							dcookies('school');
							dcookies('leader');
							dcookies('cellphone');
							dcookies('email');
							message("恭喜您,报名成功",$options['url'].'reg/',10);
						} else {
							message('上传出现错误，请后退重试。<br />如果多次无法成功上传，请联系<a href="mailto:huangjin@content.org.cn" >huangjin@content.org.cn</a>' ,60);
						}
					} else {
						message('上传出现错误，请后退重试。<br />如果多次无法成功上传，请联系<a href="mailto:huangjin@content.org.cn" >huangjin@content.org.cn</a>', 60);
					}
				}
				else message('对不起，只能上传Word2003格式的文档.', 60);
			} else {
				message('对不起，您上传的Word2003文档过大，本次上传文档并非评奖所用，请删除掉文档内的图片后，再次上传。', 60);
			}
}

if($_POST['action'] == 'vote09') {
	smessage('投票系统已经关闭');

	$userid = intval($_POST['vote']);
	if (!$userid || $userid>8 || $userid<1) {
		smessage('缺少必要参数');
	}
		$clientcode = $_POST['clientcode'];
		if (!$clientcode || strtolower($clientcode) != strtolower($seccode)) {
			$seccode = random(4, 1);
			updatesession();
			smessage('验证码错误,请返回重新输入.');
		}
		$seccode = random(4, 1);
		updatesession();
	if ($sax_group != 1 && $sax_group != 2) {
		$lastposttime = $user['lastpost'] ? $user['lastpost'] : $_COOKIE['comment_post_time'];
		if ($options['comment_post_space'] && $timestamp - $lastposttime <= $options['comment_post_space'] && $sax_group != 1){
			message('为防止灌水,发表评论时间间隔为'.$options['comment_post_space'].'秒.', $article['url'].'#addcomment');
		}
	}
		$DB->query("UPDATE {$db_prefix}vote SET votes=votes+1 WHERE id='$userid'");
		
		if ($DB->geterrdesc()) {
			smessage('出错了，请稍候再次投票');
		} else {
			smessage('投票成功');
		}
}

if($action == '09summer')
{
	
}

message('未定义操作', $referer);


// 检查用户提交内容合法性
function checkcontent($content) {
	global $options;
    if(empty($content)) {
        $result .= '内容不能为空.<br />';
        return $result;
	}
    if(strlen($content) < $options['comment_min_len']) {
        $result .= '内容不能少于'.$options['comment_min_len'].'字节.<br />';
        return $result;
	}
	if(strlen($content) > $options['comment_max_len']) {
        $result .= '内容不能超过'.$options['comment_max_len'].'字节.<br />';
        return $result;
	}
}

function xmlmsg($html) {
	@header("Content-Type: text/xml");
	echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
	echo "<root><![CDATA[".$html."]]></root>\n";
}
?>